<script setup lang="ts">
import * as echarts from "echarts";
import { onMounted, ref } from "vue"; // 引入echarts

let charts = ref();

onMounted(() => {
  // 初始化
  let myChart = echarts.init(charts.value);
  // 配置项
  myChart.setOption({
    title: {},
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      show: false,
      type: "category",
    },
    series: [
      {
        type: "bar",
        data: [58],
        barWidth: 20,
        z: 10,
        itemStyle: {
          color: "#156ACF",
          borderRadius: 20,
        },
      },
      {
        type: "bar",
        data: [100],
        barWidth: 20,
        barGap: "-100%",
        itemStyle: {
          color: "pink",
          borderRadius: 20,
        },
      },
    ],
    grid: {
      left: 0,
      right: 0,
      bottom: 0,
      top: 0,
    },
  });
});

defineOptions({
  name: "Sex",
});
</script>

<template>
  <div class="box1">
    <div class="title">
      <p>男女比例</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="sex">
      <div class="man">
        <img src="../../images/man.png" alt="" />
      </div>
      <div class="woman">
        <img src="../../images/woman.png" alt="" />
      </div>
    </div>
    <div class="rate">
      <p>男性占比 58%</p>
      <p>女性占比 42%</p>
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<style scoped lang="scss">
.box1 {
  width: 100%;
  height: 100%;
  margin-top: 10px;
  background: url("../../images/dataScreen-main-cb.png") no-repeat;
  background-size: cover;

  .title {
    margin-left: 20px;
    margin-top: 10px;
    p {
      color: white;
      font-size: 16px;
    }
  }

  .sex {
    display: flex;
    justify-content: center;
    .man {
      margin-top: 50px;
      margin-right: 50px;
      width: 111px;
      height: 115px;
      background: url("../../images/man-bg.png") no-repeat;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .woman {
      margin-top: 50px;
      margin-left: 70px;
      width: 111px;
      height: 115px;
      background: url("../../images/woman-bg.png") no-repeat;
      background-size: cover;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }

  .rate {
    margin-left: 20px;
    margin-top: 10px;
    display: flex;
    justify-content: space-around;
    p {
      color: white;
      font-size: 16px;
    }
  }

  .charts {
    margin-top: 10px;
    margin-left: 20px;
    width: 100%;
    height: 50px;
  }
}
</style>
